<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
    <head th:include="include :: header"></head>
    <body class="hold-transition skin-blue sidebar-mini">

        <section class="content-header">
            <h1>
                生产月报查询
            </h1>
        </section>
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <form id="queryForm">
                                <div class="row">
                                    <div class="form-inline">
                                        <div class="form-group" style="margin-right: 10px;">
                                            <label>年度</label>
                                            <select id="year" name="year" class="form-control">
                                                <option value="" selected="selected">请选择</option>
                                            </select>
                                        </div>
                                        <button type="button" class="btn btn-success" id="btn-search">
                                            <!--<i class="fa fa-search"></i>-->
                                            <span class="Bold">搜索</span>
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="box-body">
                            <table id="bootstrap-tree-table"></table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <div th:include="include :: footer"></div>
        <script th:inline="javascript">

            var table;

            function yearSelectCreate() {
                var date= new Date();
                var endYear = date.getFullYear();
                for (var i = endYear; i >= 2016; i--) {
                    if (i === 2016)
                        $("#year").append("<option value='" + i + "'>" + i + "年及以前" + "</option>");
                    else
                        $("#year").append("<option value='" + i + "'>" + i + "年" + "</option>");
                }
            }

            $(function () {

                yearSelectCreate();

                /**
                 * 加载列表
                 */
                table = js.treeTable.init({
                    uniqueId: "id",
                    expandFirst: false,
                    url: ctx + "integrate/month/list",
                    columns: [
                        {
                            title: '时间', field: 'dt', align: "left", width: '8%'
                        },
                        {title: '自动焊接产量', field: 'autoWeldWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '体系楼订单', field: 'systemBuildingWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '财务订单', field: 'financeWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '备库订单', field: 'spareStockWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '角铝', field: 'aluminumAngleWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '锁条', field: 'swordIronWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '非焊接类背楞', field: 'noWeldWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '焊接总产量', field: 'weldTotalWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '生产合计', field: 'outputTotalWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '模板转出', field: 'boardOutWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '特车厂', field: 'aluminumBackingWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '家具厂', field: 'aluminumSupportWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '轨道厂', field: 'bolaWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '汽车冲压厂', field: 'aluminumGasketWeight', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '外协生产合计', field: 'outSourcingTotal', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        {title: '模板总生产合计', field: 'boardTotal', align: "center",
                            formatter: function (value, row, index) {
                                if(value != null){return value.toFixed(2);}else{return ''}
                            }},
                        /*{
                            title: '操作',
                            formatter: function (value, row, index) {
                                var actions = [];
                                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="openCreatePermissionModal(' + row.id + ')"> 新增</a> ');
                                actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="openEditPermissionModal(' + row.id + ')"> 编辑</a> ');
                                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delPermission(' + row.id + ')"> 删除</a>');
                                return actions.join('');
                            }
                        }*/
                    ]
                });

                /**
                 * 表格搜索
                 */
                $("#btn-search").click(function () {
                    js.treeTable.search(table);
                });

                /**
                 * 初始化验证
                 */
                js.validate.init("permissionForm", {
                    fields: {
                        permissionName: {
                            validators: {
                                notEmpty: {message: '请输入权限码'},
                                remote: {
                                    url: ctx + "sys/permission/checkUnique",
                                    message: '权限码已存在',
                                    delay: 200,
                                    type: 'POST',
                                    data: {
                                        id: function () {
                                            return $("#id").val();
                                        }
                                    }
                                }
                            }
                        },
                        description: {validators: {notEmpty: {message: '请输入权限名'}}}
                    }
                });

                /**
                 * 创建或编辑权限
                 */
                $("#btn-create-permission").click(function () {
                    var url = ctx + "sys/permission/save";
                    if ($("#id").val()) {
                        url = ctx + "sys/permission/update";
                    }
                    js.validSubmit({
                        formId: "permissionForm",
                        url: url,
                        data: new FormData($("#permissionForm")[0]),
                        success: function (result) {
                            if (result.type === web_status.SUCCESS) {
                                js.modal.success(result.msg);
                                js.treeTable.refresh(table);
                                js.modal.hide("modal-create-permission");
                            } else {
                                js.modal.warning(result.msg);
                            }
                            js.modal.closeLoading();
                        }
                    });
                });

                /**
                 * 模态框隐藏事件， 重置表单，重置验证
                 */
                js.modal.hideEvent("modal-create-permission", function () {
                    js.validate.reset("permissionForm");
                    js.reset("permissionForm");
                })
            });
        </script>
    </body>
</html>
